<?php

/**
 * This is the model class for table "zy_feedback".
 *
 * The followings are the available columns in table 'zy_feedback':
 * @property integer $id
 * @property integer $type
 * @property string $webname
 * @property string $webvideo
 * @property integer $platform
 * @property integer $tool
 * @property string $create_time
 * @property string $update_time
 * @property string $create_user
 * @property string $update_user
 * @property integer $status
 * @property string $consequence
 */
class Feedback extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'zy_feedback';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('status,consequence,update_user,update_time','required'),
			array('type, platform, tool, status', 'numerical', 'integerOnly'=>true),
			array('webname, webvideo, create_user, update_user', 'length', 'max'=>50),
			array('consequence', 'length', 'max'=>1000),
			array('create_time, update_time', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, type, webname, webvideo, platform, tool, create_time, update_time, create_user, update_user, status, consequence', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => Yii::t('base','FID'),
			'type' => Yii::t('base','Type'),
			'webname' =>Yii::t('base','Webname'),
			'webvideo' => Yii::t('base','Webvideo'),
			'platform' => Yii::t('base','Platform'),
			'tool' => Yii::t('base','Tool'),
			'create_time' =>Yii::t('base', 'FeedBack Time'),
			'update_time' => Yii::t('base','Update Time'),
			'create_user' => Yii::t('base','FeedBack User'),
			'update_user' => Yii::t('base','Update User'),
			'status' => Yii::t('base','Status'),
			'consequence' => Yii::t('base','Consequence'),
				'user_id'=>Yii::t('base','User Id'),
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('type',$this->type);
		$criteria->compare('webname',$this->webname,true);
		$criteria->compare('webvideo',$this->webvideo,true);
		$criteria->compare('platform',$this->platform);
		$criteria->compare('tool',$this->tool);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time,true);
		$criteria->compare('create_user',$this->create_user,true);
		$criteria->compare('update_user',$this->update_user,true);
		$criteria->compare('status',$this->status);
		$criteria->compare('consequence',$this->consequence,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	
	//获取不支持的文件类型0:视频， 1：游戏  2：其他
	public function GetVideoType($type)
	{
		if($type==0)
		return Yii::t('base','Video');
		elseif ($type==1)
		return Yii::t('base','Game');
		elseif ($type==2)
		return Yii::t('base','Other');
		
		
		
	}
	//获取不支持的平台 ： int 类型，0：PC  1：IOS   2：Android   
	public function GetPlatform($platform)
	{
		if($platform==0)
			return Yii::t('base','PC');
		elseif ($platform==1)
		return Yii::t('base','IOS');
		elseif ($platform==2)
		return Yii::t('base','Android');
		
		
	}
	
	//获取不支持的工具:int类型，0：浏览器 1：应用程序（PPStream， 迅雷之类）
	public function GetTool($tool)
	{if($tool==0)
		return Yii::t('base','Browser');
		elseif ($tool==1)
		return Yii::t('base','Application Program');
		
		
		
	}
	
	//获取处理状态;1: 已完成  0:  未完成
	public function GetStatus($status)
	{
		if($status==0)
			return Yii::t('base','Unfinished');
		elseif ($status==1)
		return Yii::t('base','Finished');
		
	}
	
	
	
	
	
	
	
	
	
	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Feedback the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
